<template>
  <div>
    <div class="form_wrap">
      <el-form label-width="150px" style="margin-top: 10px">
        <el-row class="toBe">
          <el-col :span="2"> 审批信息:</el-col>
          <el-col :span="22">
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput" label="实际担保金额:">
                  <span class="pos left">小写</span>
                  <el-input
                    v-model="ht.contractGuaranteeMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（万元）</span>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="实际担期限:">
                  <el-input
                    v-model="ht.contractGuaranteeMonth"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（个月）</span>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput" label="还款方式:">
                  <el-input
                    v-model="ht.contractRepaymentModel"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :xl="2" :lg="3" style="line-height: 20px">
                <el-button
                  @click="openDiaGua"
                  v-if="showGuaranteeMoneyBtn && (orderStatus == 3 || orderStatus == 13 ||  orderStatus == 14)"
                >{{ guaTitle }}
                </el-button
                >
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <el-form label-width="150px" style="margin-top: 10px">
        <el-row>
          <el-col :span="2"> 权证信息:</el-col>
          <el-col :span="22">
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item label="公证时间:">
                  <el-date-picker
                    v-model="qz.justTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item label="二抵抵押时间:">
                  <el-date-picker
                    v-model="qz.pledgeTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item label="三抵抵押时间:">
                  <el-date-picker
                    v-model="qz.acceptTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xl="2" :lg="3" style="line-height: 20px">
                <el-button
                  @click="openWarrant"
                  v-if="showUpWarrantBtn && orderStatus == 3 || fqData"
                >{{ warrantTitle }}
                </el-button
                >
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <el-form label-width="150px" style="margin-top: 10px">
        <el-row>
          <el-col :span="2"> 服务费用信息:</el-col>
          <el-col :span="22">
            <el-row>
<!--              只显示融银贷产品-->
              <div v-if="productName=='RYD'">
                <el-col :xl="6" :lg="7">
                  <el-form-item class="posInput ts" label="总服务费:"  >
                    <el-input
                      v-model="fq.totalServiceAmount"
                      :disabled="true"
                      @input="this.$forceUpdate()"
                    ></el-input>
                  </el-form-item>
                </el-col>
                <el-col :xl="6" :lg="7">
                  <el-form-item class="posInput ts" label="前置服务费:"  >
                    <el-input
                      v-model="fq.frontServiceMoney"
                      :disabled="true"
                      @input="this.$forceUpdate()"
                    ></el-input>
                  </el-form-item>
                </el-col>
              </div>

              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="分期服务费:">
                  <el-input
                    v-model="fq.chargeMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                </el-form-item>
              </el-col>

            </el-row>
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="分期总期数:">
                  <el-input
                    v-model="fq.buyLoansYear"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（期）</span>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="分期月还款额:">
                  <el-input
                    v-model="fq.monthMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（元）</span>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="保证金:">
                  <el-input
                    v-model="margin"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（元）</span>
                </el-form-item>
              </el-col>

              <el-col :xl="2" :lg="3" style="line-height: 20px">
                <el-button
                  @click="openChargePart"
                  v-if="showChargePart && orderStatus == 3 ||  htData"
                >{{ chargePartTitle }}
                </el-button
                >
              </el-col>
              <el-col :xl="4" :lg="6" style="line-height: 20px">
                <el-button
                  :disabled="isSignContract"
                  @click="completeSigning"
                  style="background: #FD6E01FF;color: #FFFFFF"
                >已完成签约
                </el-button
                >
              </el-col>
            </el-row>

          </el-col>
        </el-row>
      </el-form>
      <el-form label-width="150px" style="margin-top: 10px">
        <el-row>
          <el-col :span="2"> 财务信息:</el-col>
          <el-col :span="22">
            <el-row style="text-align: left">
              <el-col :span="24"
              >意向申请金额：{{ yx.intentionMoney }}，意向点数{{
                  yx.intentionRatio
                }}，意向附加费{{ yx.intentionAddMoney }}，意向服务费{{
                  yx.intentionServerMoney
                }}
              </el-col
              >
            </el-row>
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="首次收费金额:">
                  <el-input
                    v-model="cw.advanceMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                  <span class="pos right">（元）</span>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item label="首次收费时间:">
                  <el-date-picker
                    v-model="cw.chargeTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item label="担保费交付时间:">
                  <el-date-picker
                    v-model="cw.chargeInvoiceTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="核算点数:">
                  <el-input
                    v-model="cw.calculateRatio"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label="核算附加费:">
                  <el-input
                    v-model="cw.calculateAddMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :xl="2" :lg="3" style="line-height: 20px">
                <el-button
                  @click="openDiaCharge"
                  v-if="showChargeBtn && (orderStatus == 3 || orderStatus == 4 || orderStatus == 12)"
                >{{ chargeTitle }}
                </el-button
                >
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
      <!--  -->
      <el-form v-if="orderStatus != 3" label-width="150px" style="margin-top: 10px">
        <el-row>
          <el-col :span="2"> 每月还款额:</el-col>
          <el-col :span="22">
            <el-row>
              <el-col :xl="6" :lg="7">
                <el-form-item class="posInput ts" label=" 还款金额:">
                  <el-input
                    v-model="my.surplusMoney"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  ></el-input>
                </el-form-item>
              </el-col>
              <el-col :xl="6" :lg="7">
                <el-form-item label="本次还款时间:">
                  <el-date-picker
                    v-model="my.obtainTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期时间"
                    align="right"
                    :disabled="true"
                    @input="this.$forceUpdate()"
                  >
                  </el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :xl="2" :lg="3" style="line-height: 20px">
                <el-button
                  @click="openChargeMy"
                  v-if="serviceCharge && (orderStatus == 3 || orderStatus == 4 || orderStatus == 12)"
                >修改
                </el-button
                >
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!--弹框-->
    <el-dialog
      title="修改信息"
      :visible.sync="dialogTableVisible"
      v-if="dialogTableVisible"
    >
      <el-form
        v-if="showdis == 1"
        :model="diaht"
        ref="diaht"
        label-width="150px"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item
              class="posInput"
              label="实际担保金额:"
              prop="contractGuaranteeMoney"
            >
              <span class="pos left">小写</span>
              <el-input v-model="diaht.contractGuaranteeMoney"></el-input>
              <span class="pos right ht-right">（万元）</span>
            </el-form-item>
          </el-col
          >
          <el-col :span="12"
          >
            <el-form-item
              class="posInput ts"
              label="实际担期限:"
              prop="contractGuaranteeMonth"
            >
              <el-input v-model="diaht.contractGuaranteeMonth"></el-input>
              <span class="pos right ht-right">（个月）</span>
            </el-form-item>
          </el-col
          >
          <el-col :span="12">
            <el-form-item
              class="posInpt"
              label="还款方式:"
              prop="contractRepaymentModel"
            >
              <!-- <el-input v-model="diaht.contractRepaymentModel"></el-input> -->
              <el-select v-model="diaht.contractRepaymentModel">
                <el-option
                  v-for="item in contractRepaymentModel"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitGua">确 定</el-button>
        </div>
      </el-form>

      <!-- 财务信息 -->
      <el-form label-width="150px" v-if="showdis == 2" :model="diacw">
        <el-row>
          <el-col :span="12">
            <el-form-item
              class="posInput ts"
              label="首次收费金额:"
              prop="advanceMoney"
            >
              <el-input v-model="diacw.advanceMoney"></el-input>
              <span class="pos right ht-right">（元）</span>
            </el-form-item>
          </el-col
          >
          <el-col :span="12"
          >
            <el-form-item label="首次收费时间:" prop="chargeTime;">
              <el-date-picker
                v-model="diacw.chargeTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
          <el-col :span="12"
          >
            <el-form-item label="担保费交付时间:" prop="chargeInvoiceTime;">
              <el-date-picker
                v-model="diacw.chargeInvoiceTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item
              class="posInput ts"
              label="核算点数:"
              prop="calculateRatio"
            >
              <el-input
                v-model="diacw.calculateRatio"
              ></el-input>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item
              class="posInput ts"
              label="核算附加费:"
              prop="calculateAddMoney"
            >
              <el-input
                v-model="diacw.calculateAddMoney"
              ></el-input>
            </el-form-item
            >
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitcharge">确 定</el-button>
        </div>
      </el-form>
      <!-- 权证信息 -->
      <el-form
        label-width="150px"
        v-if="showdis == 3"
        :model="diaqz"
        ref="diaqz"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item label="公证时间:" prop="justTime">
              <el-date-picker
                v-model="diaqz.justTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item label="二抵抵押时间:" prop="pledgeTime">
              <el-date-picker
                v-model="diaqz.pledgeTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item label="三抵抵押时间:" prop="acceptTime">
              <el-date-picker
                v-model="diaqz.acceptTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitwarrant">确 定</el-button>
        </div>
      </el-form>
      <!-- 分期信息 -->
      <el-form
        v-if="showdis == 4"
        :model="diafq"
        ref="diafq"
        label-width="150px"
      >
        <el-row type="flex" class="row-bg">
          <el-col :span="24">
            <div class="grid-content bg-purple-dark"></div>
          </el-col>
        </el-row>

        <el-row :gutter="20">
          <el-col :span="24">
            <el-button
              @click="autoInput"
              style="
                float: left;
                margin-left: 8%;
                margin-bottom: 3%;
              "
              type="primary"
            >自动填入
            </el-button
            >
          </el-col>
          <div v-if="productName=='RYD'">
            <el-col :span="12">
              <el-form-item
                class="posInput"
                label="总服务费:"
                prop="totalServiceAmount"
              >
                <el-input v-model="diafq.totalServiceAmount"></el-input>
              </el-form-item
              >
            </el-col>
            <el-col :span="12"
            >
              <el-form-item
                class="posInput ts"
                label="前置服务费:"
                prop="frontServiceMoney"
              >
                <el-input v-model="diafq.frontServiceMoney"></el-input>
                <span class="pos right ht-right">（元）</span>
              </el-form-item>
            </el-col
            >
          </div>

          <el-col :span="12">
            <el-form-item
              class="posInput"
              label="分期服务费:"
              prop="chargeMoney"
            >
              <el-input v-model="diafq.chargeMoney"></el-input>
            </el-form-item
            >
          </el-col>
          <el-col :span="12"
          >
            <el-form-item
              class="posInput ts"
              label="分期总期数:"
              prop="buyLoansYear"
            >
              <el-input v-model="diafq.buyLoansYear"></el-input>
              <span class="pos right ht-right">（期）</span>
            </el-form-item>
          </el-col
          >
          <el-col :span="12"
          >
            <el-form-item
              class="posInput ts1"
              label="分期月还款额:"
              prop="buyLoansYear"
            >
              <el-input v-model="diafq.monthMoney"></el-input>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item
              class="posInput ts"
              label="保证金:"
              prop="margin"
            >
              <el-input v-model="diafq.margin" @input="$forceUpdate()"></el-input>
              <span class="pos right">（元）</span>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitFen">确 定</el-button>
        </div>
      </el-form>
      <!-- 每月还款额 -->
      <el-form
        label-width="150px"
        v-if="showdis == 5"
        :model="diamy"
        ref="diamy"
      >
        <el-row>
          <el-col :span="12">
            <el-form-item
              class="posInput"
              label="还款金额:"
              prop="surplusMoney"
            >
              <el-input v-model="diamy.surplusMoney"></el-input>
            </el-form-item
            >
          </el-col>
          <el-col :span="12">
            <el-form-item label="本次还款时间:" prop="obtainTime">
              <el-date-picker
                v-model="diamy.obtainTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期时间"
                align="right"
              >
              </el-date-picker>
            </el-form-item
            >
          </el-col>
        </el-row>
        <div class="dialog-footer">
          <el-button @click="dialogTableVisible = false">取 消</el-button>
          <el-button type="primary" @click="submitmy">确 定</el-button>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import {
  getUpForm,
  postGuaranteeMoney,
  postChargeFen,
  putUpWarrant,
  getProductUrl,
  getIntention,
  getChargePart,
  putChargePart,
  getChargeCaiwu,
  postChargeMy,
  getChargeCount,
  margin,
  getAutoInputMargin,
  getFindOrderMessage,
  markSignCompletion
} from "../../../src/assets/js/api";
import { checkPermiss, isDiffDate } from "../../assets/js/utlis";

export default {
  name: "LoanInfor",
  props: ["orderNumber"],
  data() {
    return {
      dialogTableVisible: false,
      orderStatus: null,
      //意向
      yx: {
        intentionMoney: "--",
        intentionRatio: "--",
        intentionAddMoney: "--",
        intentionServerMoney: "--"
      },
      //合同
      ht: {
        contractGuaranteeMoney: null,
        contractGuaranteeMonth: null,
        contractRepaymentModel: null
      },
      diaht: {},
      //权证
      qz: {
        pledgeTime: null,
        justTime: null,
        acceptTime: null
      },
      diaqz: {},
      diaqzRules: {
        pledgeTime: [
          {
            type: "date",
            required: true,
            message: "请选择二抵抵押时间",
            trigger: "change"
          }
        ],
        justTime: [
          {
            type: "date",
            required: true,
            message: "请选择公正时间",
            trigger: "change"
          }
        ],
        acceptTime: [
          {
            type: "date",
            required: true,
            message: "请选择三抵抵押时间",
            trigger: "change"
          }
        ]
      },
      //财务
      cw: {
        chargeTime: null,
        advanceMoney: null,
        chargeInvoiceTime: null,
        calculateRatio: null,
        calculateAddMoney: null
      },
      fq: {
        chargeMoney: null,
        buyLoansYear: null,
        monthMoney: null,
        deposit: null, //保证金比例!
        totalServiceAmount: null, //总服务费
        frontServiceMoney: null, //前置服务费
      },
      margin: null, //保证金!
      my: {
        surplusMoney: null,
        obtainTime: null
      },
      diamy: {},
      diafq: {},
      contractRepaymentModel: [
        { lable: "等额本息", value: "等额本息" },
        { lable: "先息后本", value: "先息后本" },
        { lable: "等额本金", value: "等额本金" },
        { lable: "等额等息", value: "等额等息" }
      ],
      diacw: {},
      guaTitle: "修改",
      chargeTitle: "修改",
      warrantTitle: "修改",
      chargePartTitle: "修改",
      showdis: null,
      diaTitle: null,
      pickerOptions: {
        shortcuts: [
          {
            text: "今天",
            onClick(picker) {
              picker.$emit("pick", new Date());
            }
          },
          {
            text: "昨天",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit("pick", date);
            }
          },
          {
            text: "一周前",
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", date);
            }
          }
        ]
      },
      golbalPermissions: [],
      ProductUrl: "",
      showSignContractBtn: false,//已完成签约按钮控制
      isSignContract: false,//是否签约
      productName:'',//产品名字
    };
  },
  created() {
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
    this.getChargePart(this.orderNumber);
    this.getUpForm(this.orderNumber);
    this.findProductUrl(this.orderNumber);
    this.getIntention();
    this.getChargeCaiwu();
    this.getOrderInfo();
    this.productName=this.orderNumber.substring(0,3);
  },
  computed: {
    //审批信息监听
    htData: function() {
      if (this.ht.contractGuaranteeMoney) {
        return true;
      } else if (this.ht.contractGuaranteeMonth) {
        return true;
      }
    },
    //分期信息监听
    fqData: function() {
      if (this.fq.buyLoansYear) {
        return true;
      } else if (this.fq.chargeMoney) {
        return true;
      } else if (this.fq.deposit) {
        return true;
      } else if (this.fq.monthMoney) {
        return true;
      }
    },
    //合同数据添加按钮
    showGuaranteeMoneyBtn: function() {
      return checkPermiss(
        "business:upForm:GuaranteeMoney",
        this.golbalPermissions
      );
    },
    //权证信息添加按钮
    showUpWarrantBtn: function() {
      return checkPermiss("business:upForm:upWarrant", this.golbalPermissions);
    },
    //财务信息添加按钮
    showChargeBtn: function() {
      return checkPermiss("business:upForm:charge", this.golbalPermissions);
    },
    // 分期信息添加按钮
    showChargePart: function() {
      return checkPermiss("business:live:chargePart", this.golbalPermissions);
    },
    // 每月还款按钮
    serviceCharge: function() {
      return checkPermiss(
        "business:live:serviceCharge",
        this.golbalPermissions
      );
    }
  },
  methods: {
    //点击完成签约按钮
    completeSigning() {
      markSignCompletion(this.orderNumber).then(() => {
        this.$message.success("提交成功");
        this.isSignContract = true;
      });
    },

    //获取订单信息
    getOrderInfo() {
      getFindOrderMessage(this.orderNumber).then(res => {
        if (res.data.signCompletion) {
          this.isSignContract = true;
        } else {
          this.isSignContract = false;
        }
        let inputTime = res.data.inputTime;
        this.showSignContractBtn = isDiffDate(inputTime, "2022-05-01 00:00:00");
      });
    },
    //填写核算点数，核算附加费算出收费
    countChangeMoney() {
      if (this.diacw.calculateRatio && this.diacw.calculateAddMoney) {
        getChargeCount({
          orderNumber: this.orderNumber,
          calculateRatio: this.diacw.calculateRatio,
          calculateAddMoney: this.diacw.calculateAddMoney
        }).then((res) => {
          this.diacw.chargeMoney = res.data;
        });
      } else if (!this.diacw.calculateRatio) {
        this.$message.warning("请输入核算点数");
      } else {
        this.$message.warning("请输入核算附加费");
      }
    },
    //获取意向金额
    getIntention() {
      getIntention({ orderNumber: this.orderNumber }).then((res) => {
        if (res.data) {
          this.yx = res.data;
        }
      });
    },
    // 财务查询接口
    getChargeCaiwu() {
      getChargeCaiwu({ orderNumber: this.orderNumber }).then((res) => {
        if (res.data) {
          this.cw = res.data;
          if (
            this.cw.chargeTime == null &&
            this.cw.advanceMoney == null &&
            this.cw.chargeInvoiceTime == null &&
            this.cw.calculateRatio == null &&
            this.cw.calculateAddMoney == null
          ) {
            this.chargeTitle = "添加数据";
          }
        }
      });
    },
    //根据订单查询路由path路径
    findProductUrl(orderNumber) {
      getProductUrl({
        orderNumber: orderNumber
      }).then((res) => {
        // console.log(res.data)
        this.ProductUrl = res.data.productUrl;
        this.orderStatus = res.data.orderStatus;

        this.markUpdate = res.data.markUpdate;
      });
    },
    //根据订单号查询当前信息
    getUpForm(orderNumber) {
      let that = this;
      getUpForm({
        orderNumber: orderNumber
      }).then((res) => {
        let data = res.data;
        that.ht.contractGuaranteeMoney = data.contractGuaranteeMoney;
        that.ht.contractGuaranteeMonth = data.contractGuaranteeMonth;
        that.ht.contractRepaymentModel = data.contractRepaymentModel;
        // that.cw.chargeTime = data.chargeTime;
        // that.cw.advanceMoney = data.advanceMoney;
        if (
          that.ht.contractGuaranteeMoney == null &&
          that.ht.contractGuaranteeMonth == null
        ) {
          that.guaTitle = "添加数据";
          that.ht.contractRepaymentModel = "等额本息";
        }
        // if (that.cw.chargeMoney == null && that.cw.chargeMoney == null) {
        //   that.chargeTitle = "添加数据";
        // }
      });
    },
    // getWarrantlive(orderNumber) {
    //   let that = this;
    //   getWarrantlive({ orderNumber: orderNumber }).then(res => {
    //     let data = res.data;
    //     that.qz.pledgeTime = data.pledgeTime;
    //     that.qz.justTime = data.justTime;
    //     that.qz.acceptTime = data.acceptTime;
    //     if (
    //       that.qz.pledgeTime == null &&
    //       that.qz.justTime == null &&
    //       that.qz.acceptTime == null
    //     ) {
    //       that.warrantTitle = "添加数据";
    //     }
    //   });
    // },
    // 全部信息
    getChargePart(orderNumber) {
      let that = this;
      margin(orderNumber).then((res) => {
        that.margin = res.data; //保证金回显!
      }),
        getChargePart({ orderNumber: orderNumber }).then((res) => {
          let data = res.data;
          // that.cw.advanceMoney = data.advanceMoney;
          // that.cw.chargeTime = data.chargeTime;
          that.fq.chargeMoney = data.chargeMoney;
          that.fq.buyLoansYear = data.buyLoansYear;
          that.fq.monthMoney = data.monthMoney;
          that.fq.deposit = data.deposit;
          that.fq.totalServiceAmount = data.totalServiceAmount;
          that.fq.frontServiceMoney = data.frontServiceMoney;
          that.fq.financeInfoId = data.financeInfoId;
          this.$emit("depositMethods", that.fq.deposit);
          // 这是第一个子组件!

          if (
            that.fq.chargeMoney == null &&
            that.fq.buyLoansYear == null &&
            that.fq.monthMoney == null
          ) {
            that.chargePartTitle = "添加数据";
          }
          that.qz.pledgeTime = data.pledgeTime;
          that.qz.justTime = data.justTime;
          that.qz.acceptTime = data.acceptTime;
          if (
            that.qz.pledgeTime == null &&
            that.qz.justTime == null &&
            that.qz.acceptTime == null
          ) {
            that.warrantTitle = "添加数据";
          }
          this.my.surplusMoney = data.surplusMoney;
          this.my.obtainTime = data.obtainTime;
        });
    },
    openDiaGua() {
      this.showdis = 1;
      this.dialogTableVisible = true;
      this.diaht = JSON.parse(JSON.stringify(this.ht));
    },
    openDiaCharge() {
      this.showdis = 2;
      this.dialogTableVisible = true;
      this.diacw = JSON.parse(JSON.stringify(this.cw));
    },
    openWarrant() {
      this.showdis = 3;
      this.dialogTableVisible = true;
      this.diaqz = JSON.parse(JSON.stringify(this.qz));
    },
    openChargePart() {
      this.showdis = 4;
      this.dialogTableVisible = true;
      this.diafq = JSON.parse(JSON.stringify(this.fq));
      this.diafq.margin = this.margin;
      // console.log("this",this);
      // console.log("thisfq",this.fq);
      // console.log("diafq",this.diafq);
    },
    openChargeMy() {
      this.showdis = 5;
      this.dialogTableVisible = true;
      this.diamy = JSON.parse(JSON.stringify(this.my));
    },
    //转换日期格式
    StrToGMT(time) {
      let GMT = new Date(time);
      return GMT;
    },
    //合同提交按钮
    submitGua() {
      this.diaht.orderNumber = this.orderNumber;
      postGuaranteeMoney(this.diaht).then((res) => {
        if (res.code == 200) {
          this.getUpForm(this.orderNumber);
          this.guaTitle = "修改";
          this.dialogTableVisible = false;
          this.$message.success(res.message);
          //this.$router.push({ path: this.ProductUrl });
        }
      });
    },
    // 分期提交按钮
    submitFen() {
      this.diafq.orderNumber = this.orderNumber;
      this.diafq.deposit = Number(this.diafq.deposit);
      this.diafq.financeInfoId = this.fq.financeInfoId;
      putChargePart(this.diafq).then((res) => {
        if (res.code == 200) {
          this.getChargePart(this.orderNumber);
          this.guaTitle = "修改";
          this.dialogTableVisible = false;
          this.$message.success(res.message);
        }
      });
    },
    //财务提价按钮
    submitcharge() {
      this.diacw.orderNumber = this.orderNumber;
      if (this.diacw.chargeTime) {
        this.diacw.chargeTime = this.StrToGMT(this.diacw.chargeTime);
      }
      postChargeFen(this.diacw).then((res) => {
        if (res.code == 200) {
          this.getChargeCaiwu(this.orderNumber);
          this.chargeTitle = "修改";
          this.dialogTableVisible = false;
          this.$message.success(res.message);
          //this.$router.push({ path: this.ProductUrl });
        }
      });
    },
    // 权证提交按钮
    submitwarrant() {
      this.diaqz.orderNumber = this.orderNumber;
      if (this.diaqz.justTime != null) {
        this.diaqz.justTime = this.StrToGMT(this.diaqz.justTime);
      }
      if (this.diaqz.pledgeTime != null) {
        this.diaqz.pledgeTime = this.StrToGMT(this.diaqz.pledgeTime);
      }
      if (this.diaqz.acceptTime != null) {
        this.diaqz.acceptTime = this.StrToGMT(this.diaqz.acceptTime);
      }
      // this.diaqz.justTime = this.StrToGMT(this.diaqz.justTime);
      // this.diaqz.pledgeTime = this.StrToGMT(this.diaqz.pledgeTime);
      // this.diaqz.acceptTime = this.StrToGMT(this.diaqz.acceptTime);
      putUpWarrant(this.diaqz).then((res) => {
        if (res.code == 200) {
          this.getChargePart(this.orderNumber);
          this.warrantTitle = "修改";
          this.dialogTableVisible = false;
          this.$message.success(res.message);
          //this.$router.push({ path: this.ProductUrl });
        }
      });
    },
    // 每月还款额
    submitmy() {
      this.diamy.orderNumber = this.orderNumber;
      if (this.diamy.obtainTime) {
        this.diamy.obtainTime = this.StrToGMT(this.diamy.obtainTime);
      }
      postChargeMy(this.diamy).then((res) => {
        if (res.code == 200) {
          this.getChargePart(this.orderNumber);
          this.dialogTableVisible = false;
          this.$message.success(res.message);
          //this.$router.push({ path: this.ProductUrl });
        }
      });
    },
    //保证金自动填入
    autoInput() {
      getAutoInputMargin(this.orderNumber).then((res) => {
        this.diafq.chargeMoney = res.data.charge;
        this.diafq.buyLoansYear = res.data.month;
        this.diafq.monthMoney = res.data.monthly;
        this.diafq.frontServiceMoney = res.data.frontServiceMoney;
        this.diafq.totalServiceAmount = res.data.totalServiceAmount;
      });
    }
  }
};
</script>

<style scoped type="less">
.posInput {
  position: relative;
}

.pos {
  position: absolute;
  z-index: 2;
}

.pos.left {
  left: 10px;
}

.pos.right {
  right: 0;
}

.posInput ::v-deep .el-input__inner {
  padding: 0 50px 0 40px;
  text-align: center;
}

.posInput.ts ::v-deep .el-input__inner {
  padding-left: 25px;
}

.toBe {
  line-height: 35px;
}

.form_wrap ::v-deep .el-form-item,
.form_wrap ::v-deep .el-form-item__label,
.form_wrap ::v-deep .el-form-item__content,
.form_wrap ::v-deep .el-input,
.form_wrap ::v-deep .el-input__inner {
  line-height: 32px;
  height: 32px;
}

.form_wrap ::v-deep .el-form-item {
  margin-bottom: 5px;
}

.form_wrap ::v-deep .el-col {
  line-height: 32px;
}

.form_wrap ::v-deep .el-button {
  padding: 8px 20px;
}

.form_wrap ::v-deep.el-input__icon {
  line-height: 24px;
}

::v-deep .el-form-item__content {
  text-align: left;
}

.el-date-editor.el-input {
  width: 100%;
}


</style>
